package com.htu.tax.controller;


import com.htu.tax.common.ResponseHelper;
import com.htu.tax.common.ResponseModel;

import com.htu.tax.payload.request.company.AddCompanyRequest;
import com.htu.tax.payload.request.company.GetCompanyRequest;
import com.htu.tax.payload.request.company.UpdateCompanyRequest;
import com.htu.tax.payload.request.company.UpdateCompanyStateRequest;
import com.htu.tax.service.CompanyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


@RestController
@CrossOrigin
@Api(tags = "物流企业接口")
@RequestMapping("/company")
public class CompanyController {
    @Resource
    private CompanyService companyService;
    /*
    public CompanyController(CompanyService companyService){
        this.companyService=companyService;
    }
    */

    @ApiOperation("物流企业添加")
    @PostMapping("/addCompany")
    public ResponseModel addCompany(@RequestBody AddCompanyRequest request) {
        companyService.addCompany(request);
        return ResponseHelper.buildResponseModel("添加成功");
    }

    @ApiOperation("查询物流企业列表")
    @PostMapping("/getCompany")
    public ResponseModel getCompany(GetCompanyRequest request) {
        return ResponseHelper.buildResponseModel(companyService.getCompany(request));
    }

    @ApiOperation("物流企业修改")
    @PostMapping("/updateCompany")
    public ResponseModel updateCompany(@RequestBody UpdateCompanyRequest request) {
        companyService.updateCompany(request);
        return ResponseHelper.buildResponseModel("修改成功");
    }

    @ApiOperation("修改物流企业状态")
    @PostMapping("/updateCompanyState")
    public ResponseModel updateCompanyState(@RequestBody UpdateCompanyStateRequest request) {
        companyService.updateCompanyState(request);
        return ResponseHelper.buildResponseModel("认证成功");
    }
}